package com.google.code.gaeapptest.util;

import java.util.logging.Logger;

import com.google.code.gaeapptest.junit.SqlTests;

public class AppEngineUtil {
	private static final Logger LOG = Logger
			.getLogger(SqlTests.class.getName());
	public static String environment;
	public static String applicationId;
	public static String version;
	public static String url;
	public static String instancePrefix;
	public static String connectString;
	public static String dbInstanceName;
	public static String dbName;
	static {
		instancePrefix = "systemsplanet.com:apptest:";
		dbName = "apptest";

		environment = System
				.getProperty("com.google.appengine.runtime.environment");
		applicationId = System
				.getProperty("com.google.appengine.application.id");
		version = System
				.getProperty("com.google.appengine.application.version");

		if ("Production".equals(environment)) {
			url = "http://" + version + "." + applicationId + ".appspot.com/";
		} else {
			version = "1";
			applicationId = "local";
			url = "http://localhost:8888";
		}
		dbInstanceName = AppEngineUtil.instancePrefix
				+ AppEngineUtil.applicationId;
		connectString = "jdbc:google:rdbms://" + dbInstanceName + "/" + dbName;
		LOG.info("connectString:[" + AppEngineUtil.connectString + "]");
	}
}
